with v8.Class_Stack_Frame, v8.Class_Array;
package v8.Class_Stack_Trace is
   type Stack_Trace (<>) is tagged limited private;
   type Pointer is access all Stack_Trace;
   -- Representation of a JavaScript stack trace. The information collected is a
   -- snapshot of the execution stack and the information remains valid after
   -- execution continues.


   function Get_Frame
     (this  : Stack_Trace;
      index : uint32_t
     ) return v8.Class_Stack_Frame.Pointer;  -- Local<Stack_Frame>
   -- Returns a Stack_Frame at a particular index.

   function Get_Frame_Count
     (this : Stack_Trace
     ) return int;
   -- Returns the number of Stack_Frames.

   function As_Array
     (this : in out Stack_Trace
     ) return v8.Class_Array.Pointer;  -- Local<Array>
   -- Returns Stack_Trace as a v8::Array that contains Stack_Frame objects.

   function Current_Stack_Trace
     (frame_limit : int;
      options     : Stack_Trace_Options.Enum := Stack_Trace_Options.k_Over_View
     ) return Pointer;  -- Local<Stack_Trace>
   -- Grab a snapshot of the current JavaScript execution stack.
   --
   -- \param frame_limit The maximum number of stack frames we want to capture.
   -- \param options Enumerates the set of things we will capture for each
   --   StackFrame.


private
   type Stack_Trace is tagged limited null record;

   pragma Import (CPP, Get_Frame, "_ZNK2v810StackTrace8GetFrameEj");
      pragma Import (CPP, Get_Frame_Count, "_ZNK2v810StackTrace13GetFrameCountEv");
      pragma Import (CPP, As_Array, "_ZN2v810StackTrace7AsArrayEv");
      pragma Import (CPP, Current_Stack_Trace, "_ZN2v810StackTrace17CurrentStackTraceEiNS0_17StackTraceOptionsE");
end v8.Class_Stack_Trace;
